﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>日期字段输入控制</title>
    <link href="../../../Scripts/easyUI145/themes/default/easyui.css" rel="stylesheet" />
    <script type="text/javascript" src="../../../Scripts/bootstrap/js/jquery.min.js"></script>
    <script src="../../../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../../../Scripts/config.js" type="text/javascript"></script>
    <script src="../../../Comm/Gener.js" type="text/javascript"></script>
    <link href="../../../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
    <script src="../../Admin.js"></script>
    <base target="_self" />
    <script type="text/javascript">

        //页面启动函数.
        $(function () {

            var frmID = GetQueryString("FK_MapData");
            var keyOfEn = GetQueryString("KeyOfEn");

            //组织主键.
            var mypk = "DataFieldInputRole_" + GetQueryString("FK_MapData") + "_" + keyOfEn;
            var en = new Entity("BP.Sys.MapExt");
            en.MyPK = mypk;
            var i = en.RetrieveFromDBSources();

            if (i == 0)
                $("#Btn_Delete").attr("disabled", true);
            else
                $("#Btn_Delete").removeAttr("disabled");

            //设置文本框选择的值.
            $("#RB_" + en.DoWay).attr("checked", true);
            //绑定外键.
            var tables = new Entities("BP.Sys.MapAttrs");
            tables = tables.DoMethodReturnJSON("SearchMapAttrsDateAndDateTime", frmID);

            //tables.Retrieve("FK_MapData", frmID, "MyDataType", 6);
            GenerBindDDL("DDL_DT", tables, "KeyOfEn", "Name", en.Tag4);

            //加上时间类型的.
            tables = new Entities("BP.Sys.MapAttrs");
            tables = tables.DoMethodReturnJSON("SearchMapAttrsDateAndDateTime", frmID);

           // tables.Retrieve("FK_MapData", frmID, "MyDataType", 7);

            GenerBindDDLAppend("DDL_DT", tables, "KeyOfEn", "Name");

            if (en.Tag1 == 1)
                document.getElementById("CB_History").checked = true;
            else
                document.getElementById("CB_History").checked = false;
            if (en.Tag2 == 1) {
                document.getElementById("CB_Impose").checked = true;
                $("#DDL_Condition").val(en.Tag3);
                $("#DDL_DT").val(en.Tag4);
            }
            else
                document.getElementById("CB_Impose").checked = false;
            
        });

        //执行保存
        function Save() {

            //组织主键.
            var mypk = "DataFieldInputRole_" + GetQueryString("FK_MapData") + "_" + GetQueryString("KeyOfEn");
            var en = new Entity("BP.Sys.MapExt");
            en.MyPK = mypk;
            en.RetrieveFromDBSources();

            en.FK_MapData = GetQueryString("FK_MapData");
            en.AttrOfOper = GetQueryString("KeyOfEn");
            en.ExtType = "DataFieldInputRole";
            en.MyPK = mypk;

            var checkVal = $("input[name='RB']:checked").val();
            en.DoWay = checkVal;

            //是否启用了历史数据.
            var history = document.getElementById("CB_History").checked;
            if (history == true)
                en.Tag1 = 1;
            else
                en.Tag1 = 0;

            //是否用了日期限制规则
            var impose = document.getElementById("CB_Impose").checked;
            if (impose == true) {
                en.Tag2 = 1;
                en.Tag3 = $("#DDL_Condition").val();
                en.Tag4 = $("#DDL_DT").val();
            }
            else {
                en.Tag2 = 0;
                en.Tag3 = "";
                en.Tag4 = "";
            }

            if (en.Update() == 0)
                en.Insert();

            SetHref("DataFieldInputRole.htm?FK_MapData=" + GetQueryString("FK_MapData") + "&KeyOfEn=" + GetQueryString("KeyOfEn") + "&M=" + Math.random());
            return;
        }

        //删除.
        function Delete() {

            if (window.confirm('您确定要删除吗？') == false)
                return;

            var mypk = "DataFieldInputRole_" + GetQueryString("FK_MapData") + "_" + GetQueryString("KeyOfEn");
            var en = new Entity("BP.Sys.MapExt");
            en.MyPK = mypk;
            en.RetrieveFromDBSources();
            en.Delete();

            var url = "DataFieldInputRole.htm?FK_MapData=" + GetQueryString("FK_MapData") + "&KeyOfEn=" + GetQueryString("KeyOfEn");
            SetHref(url);
        }
    </script>
</head>
<body>
    <div class="container-full">
        <div class="attrnode-bar-header">
            <span class="pull-right">
                <input type="button" value="保存" id="Btn_Save" class="cc-btn-tab" onclick="Save()" />
                <input type="button" value="删除" id="Btn_Delete" class="cc-btn-tab" onclick="Delete()" />
                <input type="button" value="帮助" id="Btn_Help" class="cc-btn-tab" onclick="ShowHidden('help')" />
            </span>
            <strong> 日期字段输入控制</strong>
        </div>
        <form id="cc">
            <div class="form-group">
                <label for="RB_0" class="radio-inline"> <input type="radio" value="0" id="RB_0" name="RB" /> 无，不做任何设置.</label>

                <label for="RB_1" class="radio-inline"> <input type="radio" value="1" id="RB_1" name="RB" />启用设置</label>
            </div>
            <div class="form-group" style="border-bottom: 1px solid #eee;">&nbsp; </div>
            <div class="form-group">
                <label class="radio-inline">
                    <input type="radio" id="CB_History" name="CB_RDT" />
                    不能输入历史日期，只能输入当前日期以及未来日期。
                </label>
            </div>
            <div class="form-group">
                <label class="radio-inline">
                    <input type="radio" id="CB_Impose" name="CB_RDT" />
                    只能输入指定运算符(如大于等于)指定字段的日期。
                </label>
            </div>
            <div class="form-group">
                运算符：<select id="DDL_Condition" >
                    <option value="dayu">大于 </option>
                    <option value="dayudengyu">大于等于 </option>
                    <option value="xiaoyu">小于 </option>
                    <option value="xiaoyudengyu">小于等于 </option>
                    <option value="budengyu">不等于 </option>
                </select>
                指定的:<select id="DDL_DT">
                    <option></option>
                </select>字段日期
            </div>


          
            <div id="help" style="color: Gray; display: none">
                <ul>
                    <li>该功能提供了简单的、常用的日期输入判断限制规则。</li>
                    <li>如果需要更复杂高级的判断请使用事件绑定函数，把业务逻辑写入到函数里面判定。</li>
                    <li>如果要启用日期输入不能为空的限制，请到该字段基本信息里设置。</li>
                </ul>
            </div>


        </form>
    </div>
</body>
</html>
